function varargout = GUI_INI_TP(varargin)
% GUI_INI_TP MATLAB code for GUI_INI_TP.fig
%      GUI_INI_TP, by itself, creates a new GUI_INI_TP or raises the existing
%      singleton*.
%
%      H = GUI_INI_TP returns the handle to a new GUI_INI_TP or the handle to
%      the existing singleton*.
%
%      GUI_INI_TP('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI_INI_TP.M with the given input arguments.
%
%      GUI_INI_TP('Property','Value',...) creates a new GUI_INI_TP or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_INI_TP_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI_INI_TP_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help GUI_INI_TP

% Last Modified by GUIDE v2.5 09-Feb-2015 14:10:12

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUI_INI_TP_OpeningFcn, ...
                   'gui_OutputFcn',  @GUI_INI_TP_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
%--------------------------------------------------------------------------


% --- Executes just before GUI_INI_TP is made visible.
function GUI_INI_TP_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to GUI_INI_TP (see VARARGIN)
%--------------------------------------------------------------------------
indexEdit = 0;
switch indexEdit 
    case 0
        %--------------------------------------------------------------------------
        dontOpen = false;
        mainGuiInput = find(strcmp(varargin, 'OSCILOS_long'));
        if (isempty(mainGuiInput)) ...
            || (length(varargin) <= mainGuiInput) ...
            || (~ishandle(varargin{mainGuiInput+1}))
            dontOpen = true;
        else % load from the main GUI
            % handles of main GUI
            handles.MainGUI = varargin{mainGuiInput+1};
            try
                handles.ExampleGUI = varargin{mainGuiInput+2};
            catch
            end
            % Obtain handles using GUIDATA with the caller's handle 
            mainHandles = guidata(handles.MainGUI);
            % background colors
            handles.bgcolor=mainHandles.bgcolor;
            % fontsize
            handles.FontSize=mainHandles.FontSize;
            %
            handles.sW = mainHandles.sW;
            handles.sH = mainHandles.sH;
            % Update handles structure
            guidata(hObject, handles);
            % Initialization
            GUI_INI_TP_Initialization(hObject, eventdata, handles)
            handles = guidata(hObject);
            guidata(hObject, handles);
        end
        guidata(hObject, handles);
        handles.output = hObject;
        guidata(hObject, handles);
        if dontOpen
           disp('-----------------------------------------------------');
           disp('This is a subprogram. It cannot be run independently.') 
           disp('Please load the program "OSCILOS_long'' from the ')
           disp('parent directory!')
           disp('-----------------------------------------------------');
        else
%            uiwait(hObject);
        end
    case 1
        addpath(genpath('./'))                    % add directories to search path
        global CI
        handles.bgcolor{1} = [0.95, 0.95, 0.95];
        handles.bgcolor{2} = [0, 0, 0];
        handles.bgcolor{3} = [.75, .75, .75];
        handles.bgcolor{4} = [0.90,0.90,1];
        %
        handles.sW  = 800;
        handles.sH  = 600;
        %
        if ispc
            handles.FontSize(1)=11;                 % set the default fontsize
            handles.FontSize(2)=9;
        else
            handles.FontSize(1)=12;                 % set the default fontsize
            handles.FontSize(2)=10;   
        end
        CI.IsRun.GUI_INI_TP = 0;
        assignin('base','CI',CI);                   % save the current information to the works
        guidata(hObject, handles);  
        GUI_INI_TP_Initialization(hObject, eventdata, handles)
        handles = guidata(hObject);
        guidata(hObject, handles);
        handles.output = hObject;
        guidata(hObject, handles);
end
%
%
function GUI_INI_TP_Initialization(varargin)
hObject = varargin{1};
handles = guidata(hObject);
%--------------------------------------
set(0, 'units', 'points');
screenSize  = get(0, 'ScreenSize');                 % get the screen size
sW          = handles.sW;                           % screen width
sH          = handles.sH ;                          % screen height
FigW=sW.*8/10;                                        % window width
FigH=sH.*8.0/10;                                        % window height
set(handles.figure,     'units', 'points',...
                        'position',[(screenSize(3)-FigW)./2 (screenSize(4)-FigH)./2 FigW FigH],...
                        'name','Mean flow and thermal properties configuration',...
                        'color',handles.bgcolor{3});
NameFuel={  'CH4_Methane','C2H4_Ethylene','C2H6_Ethane','C3H8_Propane',...
            'C4H8_Butene','C4H10_n_butane',...
            'C4H10_isobutane','C12H23_Jet_A(g)'};                    
%----------------------------------------
% pannel axes
set(handles.uipanel_axes,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[FigW*0.5/20 FigH*11.5/20 FigW*19/20 FigH*8.25/20],...
                        'Title','Plots:',...
                        'visible','on',...
                        'highlightcolor',handles.bgcolor{3},...
                        'borderwidth',1,...
                        'fontsize',handles.FontSize(2),...
                        'backgroundcolor',handles.bgcolor{3});  
pannelsize=get(handles.uipanel_axes,'position');
pW=pannelsize(3);
pH=pannelsize(4);                
set(handles.axes1,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*1/10 pH*2/10 pW*8/10 pH*6/10],...
                        'fontsize',handles.FontSize(1),...
                        'color',handles.bgcolor{1});
set(handles.axes2,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*1/10 pH*2/10 pW*6/10 pH*3.5/10],...
                        'fontsize',handles.FontSize(1),...
                        'color',handles.bgcolor{1},...
                        'visible','off');
                    
set(handles.text_plot,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*8/10 pH*8/10 pW*1.75/10 pH*0.75/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Plot:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left',...
                        'visible','off');
set(handles.pop_plot,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*1/10 pH*8.0/10 pW*4/10 pH*1.25/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',{'Mean velocity';'Mean temperature'},...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','left');
set(handles.pb_Plot,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*8/10 pH*5/10 pW*1.75/10 pH*0.9/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Plot figure',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'visible','off',...
                        'enable','off');  
set(handles.pb_saveFig,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*8/10 pH*3.5/10 pW*1.75/10 pH*0.9/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Save figure',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'visible','off',...
                        'enable','off');  
%----------------------------------------                    
% pannel initial thermal properties
set(handles.uipanel_ITP,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[FigW*0.5/20 FigH*8.0/20 FigW*19/20 FigH*3.5/20],...
                        'Title','Inlet mean flow properties',...
                        'visible','on',...
                        'highlightcolor',handles.bgcolor{3},...
                        'borderwidth',1,...
                        'fontsize',handles.FontSize(2),...
                        'backgroundcolor',handles.bgcolor{3});  
pannelsize=get(handles.uipanel_ITP,'position');
pW=pannelsize(3);
pH=pannelsize(4); 
set(handles.text_TP_p1,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*0.25/10 pH*5.25/10 pW*1.5/10 pH*1.5/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','p1_mean [Pa]:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left');                    
set(handles.edit_TP_p1,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*1.75/10 pH*5/10 pW*1.25/10 pH*2.25/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',101325,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','right');                    
set(handles.text_TP_T1,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*3.5/10 pH*5.25/10 pW*1.5/10 pH*1.5/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','T1_mean [K]:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left');                    
set(handles.edit_TP_T1,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*5/10 pH*5/10 pW*1.25/10 pH*2.25/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',293.15,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','right');
set(handles.pop_TP_M1_u1,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*6.5/10 pH*5.25/10 pW*1.5/10 pH*2.0/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',{'M1_mean [-]:';'u1_mean [m/s]:'},...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','left',...
                        'enable','on',...
                        'value',1);                    
set(handles.edit_TP_M1,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*8.25/10 pH*5./10 pW*1.25/10 pH*2.25/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',0.01,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','right');
set(handles.text_gamma,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*0.25/10 pH*1.5/10 pW*3.5/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Specific heat capacity ratio gamma:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left',...
                        'visible', 'on', 'enable', 'on');  
set(handles.pop_gamma,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*4/10 pH*1.75/10 pW*4/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',{'constant';'change with temperature'},...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','left',...
                        'enable','on',...
                        'value',2, 'visible', 'on',  'enable', 'on');  

%----------------------------------------                    
% pannel heat addition style 
set(handles.uipanel_HA_style,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[FigW*0.5/20 FigH*4.5/20 FigW*19/20 FigH*3.5/20],...
                        'Title','Heat addition style',...
                        'visible','on',...
                        'highlightcolor',handles.bgcolor{3},...
                        'borderwidth',1,...
                        'fontsize',handles.FontSize(2),...
                        'backgroundcolor',handles.bgcolor{3});  
pannelsize=get(handles.uipanel_HA_style,'position');
pW=pannelsize(3);
pH=pannelsize(4); 
set(handles.text_HA_num,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*0.25/10 pH*1.5/10 pW*1.5/10 pH*4.0/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Heat from:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left',...
                        'visible','off');                         
set(handles.pop_HA_num,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*0.25/10 pH*5.5/10 pW*3.5/10 pH*2.0/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',{  'Heat source number: 1';...
                                    'Heat source number: 2'},...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','left',...
                        'enable','on',...
                        'value',1);     
set(handles.text_HA_style,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*0.25/10 pH*1.5/10 pW*1.5/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Heat from:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left');                         
set(handles.pop_HA_style,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*1.5/10 pH*2.0/10 pW*2/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',{  'Heating grid (Tb/Tu is given)';...
                                    'Fuel combustion'},...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','left',...
                        'enable','on',...
                        'value',1);  
set(handles.text_TD_Tratio,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*4.0/10 pH*1.5/10 pW*4/10 pH*2.0/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Temperature ratio across the flame Tb/Tu [-]:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left');
set(handles.edit_TD_Tratio,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*8.25/10 pH*2.0/10 pW*2.5/20 pH*2.25/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',1,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','right',...
                        'enable','on');
set(handles.text_HR,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*4.0/10 pH*5.25/10 pW*4/10 pH*2.0/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Heat release rate Q [kW]:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left');
set(handles.edit_HR,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*8.25/10 pH*5.5/10 pW*2.5/20 pH*2.25/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',0,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','right',...
                        'enable','off');
%---------------------------------------- 
% pannel heat addition configuration
set(handles.uipanel_Heat_Config,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[FigW*0.5/20 FigH*1.75/20 FigW*19/20 FigH*3.5/20],...
                        'Title','',...
                        'visible','on',...
                        'highlightcolor',handles.bgcolor{3},...
                        'borderwidth',1,...
                        'fontsize',handles.FontSize(2),...
                        'backgroundcolor',handles.bgcolor{3});  
pannelsize=get(handles.uipanel_Heat_Config,'position');
pW=pannelsize(3);
pH=pannelsize(4);  
% row 1  
set(handles.text_FD_fuel,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*0.5/10 pH*5/10 pW*1.5/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Fuel:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left'); 
set(handles.pop_FD_fuel,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*1.5/10 pH*5.25/10 pW*2.0/10 pH*2.25/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',NameFuel,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','left',...
                        'enable','off');

set(handles.text_FD_CbEff,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*5.5/10 pH*5/10 pW*3/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Combustion efficiency:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left'); 
set(handles.edit_FD_effi,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*8.25/10 pH*5/10 pW*1.25/10 pH*2.25/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',1,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','right',...
                        'enable','off');                    
% row 2  
set(handles.text_FD_phi,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*0.5/10 pH*1.5/10 pW*3.0/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Equivalence ratio [-]:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left');
set(handles.edit_FD_phi,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*3.25/10 pH*1.5/10 pW*1.25/10 pH*2.25/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',1,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','right',...
                        'enable','off');
set(handles.text_FD_dilute,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*5.5/10 pH*1.5/10 pW*3.0/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Dilution ratio [-]:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left',...
                        'visible', 'off');
set(handles.edit_FD_dilute,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*8.25/10 pH*1.5/10 pW*1.25/10 pH*2.25/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',0,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','right',...
                        'enable','off',...
                        'visible', 'off');                                 
%---------------------------------------- 
% pannel heat addition style 
set(handles.uipanel_FlameDistStyle,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[FigW*0.5/20 FigH*8.0/20 FigW*19/20 FigH*1.75/20],...
                        'Title','Heat addition style',...
                        'visible','off',...
                        'highlightcolor',handles.bgcolor{3},...
                        'borderwidth',1,...
                        'fontsize',handles.FontSize(2),...
                        'backgroundcolor',handles.bgcolor{3});
%----------------------------------------                    
% pannel flame distribution
set(handles.uipanel_flameDist,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[FigW*5.5/20 FigH*2.25/20 FigW*14/20 FigH*3.25/20],...
                        'Title','Initial thermal properties',...
                        'visible','off',...
                        'highlightcolor',handles.bgcolor{3},...
                        'borderwidth',1,...
                        'fontsize',handles.FontSize(2),...
                        'backgroundcolor',handles.bgcolor{3});  
pannelsize=get(handles.uipanel_flameDist,'position');
pW=pannelsize(3);
pH=pannelsize(4); 
set(handles.text_DT_flameW,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*0.5/10 pH*5/10 pW*2.5/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Flame length [mm]:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left'); 
set(handles.edit_DT_flameW,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*3/10 pH*5.5/10 pW*1.5/10 pH*2.2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',0,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','right',...
                        'enable','off');
set(handles.text_DT_distS,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*5/10 pH*5/10 pW*2/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Distributed form:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left');                                                                              
set(handles.pop_DT_distS,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*7.25/10 pH*4.5/10 pW*2.5/10 pH*3/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',{'Uniform distribution:';'Triangular distribution';'Gaussian distribution'; 'Conical flame'},...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','left',...
                        'enable','off');
set(handles.text_DT_SN,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*0.5/10 pH*1/10 pW*2.5/10 pH*2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Sample number [-]:',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'horizontalalignment','left'); 
set(handles.edit_DT_SN,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*3/10 pH*1.5/10 pW*1.5/10 pH*2.2/10],...
                        'fontsize',handles.FontSize(2),...
                        'string',10,...
                        'backgroundcolor',handles.bgcolor{1},...
                        'horizontalalignment','right',...
                        'enable','off');
%----------------------------------------
% pannel Apply OK Cancel                   
set(handles.uipanel_OK,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[FigW*0.5/20 FigH*0/20 FigW*19/20 FigH*1.5/20],...
                        'Title','',...
                        'visible','on',...
                        'highlightcolor',handles.bgcolor{3},...
                        'borderwidth',1,...
                        'fontsize',handles.FontSize(2),...
                        'backgroundcolor',handles.bgcolor{3}); 
pannelsize=get(handles.uipanel_OK,'position');                    
pW=pannelsize(3);
pH=pannelsize(4);                
set(handles.pb_Cal,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*0.7/10 pH*2/10 pW*2.4/10 pH*6/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Calculate...',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'enable','on');
set(handles.pb_OK,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*3.8/10 pH*2/10 pW*2.4/10 pH*6/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','OK',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'enable','off');
set(handles.pb_Cancel,...
                        'units', 'points',...
                        'Fontunits','points',...
                        'position',[pW*6.9/10 pH*2/10 pW*2.4/10 pH*6/10],...
                        'fontsize',handles.FontSize(2),...
                        'string','Cancel',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'enable','on'); 
%
%---------------------------------------
handles.ObjEditEnable_TP = findobj('-regexp','Tag','_TP_');
handles.ObjEditEnable_FD = findobj('-regexp','Tag','_FD_');
% default enable settings
set(handles.ObjEditEnable_TP,    'Enable','on');
set(handles.ObjEditEnable_FD,    'Enable','off');
guidata(hObject, handles);
%
% ------------------check if the program has ever been run-----------------
GUI_INI_TP_IsEverRun_check(hObject);
handles = guidata(hObject);
guidata(hObject, handles);
%
%
%-------------------------------------------------------------------------

% --- Outputs from this function are returned to the command line.
function varargout = GUI_INI_TP_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
try
varargout{1} = handles.output;
end
%
% ----------------Mean flow properties pannel------------------------------
%
function edit_TP_p1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_TP_p1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
datEdit = str2double(get(hObject, 'String'));
ValDefault = 101325; 
if isnan(datEdit) || ~isreal(datEdit) ||datEdit < 0
    set(hObject, 'String', ValDefault);
    errordlg('Input must be a non-negative real number','Error');
    % when the input is not a number, it is set to the default value
end
GUI_INI_TP_disable_button(hObject)

% --- Executes during object creation, after setting all properties.
function edit_TP_p1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_TP_p1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit_TP_T1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_TP_T1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
datEdit = str2double(get(hObject, 'String'));
ValDefault = 293.15; 
if isnan(datEdit) || ~isreal(datEdit) ||datEdit < 0
    set(hObject, 'String', ValDefault);
    errordlg('Input must be a non-negative real number','Error');
    % when the input is not a number, it is set to the default value
end
GUI_INI_TP_disable_button(hObject)

% --- Executes during object creation, after setting all properties.
function edit_TP_T1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_TP_T1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit_TP_M1_Callback(hObject, eventdata, handles)
% hObject    handle to edit_TP_M1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
datEdit = str2double(get(hObject, 'String'));
ValDefault = 1e-3; 
if isnan(datEdit) || ~isreal(datEdit) ||datEdit < 0
    set(hObject, 'String', ValDefault);
    errordlg('Input must be a non-negative real number','Error');
    % when the input is not a number, it is set to the default value
end
GUI_INI_TP_disable_button(hObject)


% --- Executes on selection change in pop_TP_M1_u1.
function pop_TP_M1_u1_Callback(hObject, eventdata, handles)
% hObject    handle to pop_TP_M1_u1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns pop_TP_M1_u1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from pop_TP_M1_u1
pop_type_MU = get(hObject,'value');
global CI
switch pop_type_MU 
    case 1
        set(handles.edit_TP_M1,'string','0.01')
        try
        set(handles.edit_TP_M1,'string',num2str(CI.TP.M_mean(1,1)))
        catch
        end
    case 2
        set(handles.edit_TP_M1,'string','10')
        try
        set(handles.edit_TP_M1,'string',num2str(CI.TP.u_mean(1,1)))
        catch
        end
end

% --- Executes during object creation, after setting all properties.
function pop_TP_M1_u1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to pop_TP_M1_u1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes during object creation, after setting all properties.
function edit_TP_M1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_TP_M1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% ----------------Heat addition style--------------------------------------
%
% --- Executes on selection change in pop_HA_style.
function pop_HA_style_Callback(hObject, eventdata, handles)
% hObject    handle to pop_HA_style (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns pop_HA_style contents as cell array
%        contents{get(hObject,'Value')} returns selected item from pop_HA_style
handles=guidata(hObject);
pop_HA_style=get(hObject,'Value');
switch pop_HA_style
% {  'heater (Tb/Tu is given)';...
%    'combustion'}
    case 1
        set(handles.edit_TD_Tratio,             'Enable', 'on')
        set(handles.ObjEditEnable_FD,           'Enable', 'off')
    case 2
        set(handles.edit_TD_Tratio,             'Enable', 'off')
        set(handles.ObjEditEnable_FD,           'Enable', 'on')
 end
guidata(hObject, handles);
GUI_INI_TP_disable_button(hObject)

% --- Executes during object creation, after setting all properties.
function pop_HA_style_CreateFcn(hObject, eventdata, handles)
% hObject    handle to pop_HA_style (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
%

% --- Executes on selection change in pop_HA_num.
function pop_HA_num_Callback(hObject, eventdata, handles)
% hObject    handle to pop_HA_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns pop_HA_num contents as cell array
%        contents{get(hObject,'Value')} returns selected item from pop_HA_num
global CI
Fcn_GUI_INI_TP_HA_UI2Para(hObject,CI.TP.HA_num);
Fcn_GUI_INI_TP_HA_Para2UI(hObject);

% --- Executes during object creation, after setting all properties.
function pop_HA_num_CreateFcn(hObject, eventdata, handles)
% hObject    handle to pop_HA_num (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% ----------------Heat addition from flame pannel--------------------------
%
function edit_FD_effi_Callback(hObject, eventdata, handles)
% hObject    handle to edit_FD_effi (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
datEdit = str2double(get(hObject, 'String'));
ValDefault = 1;   % combustion efficiency
if isnan(datEdit) || ~isreal(datEdit) ||datEdit < 0
    set(hObject, 'String', ValDefault);
    errordlg('Input must be a non-negative real number','Error');
    % when the input is not a number, it is set to the default value
end
GUI_INI_TP_disable_button(hObject)

% --- Executes during object creation, after setting all properties.
function edit_FD_effi_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_FD_effi (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in pop_FD_fuel.
function pop_FD_fuel_Callback(hObject, eventdata, handles)
% hObject    handle to pop_FD_fuel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns pop_FD_fuel contents as cell array
%        contents{get(hObject,'Value')} returns selected item from pop_FD_fuel
GUI_INI_TP_disable_button(hObject)

% --- Executes during object creation, after setting all properties.
function pop_FD_fuel_CreateFcn(hObject, eventdata, handles)
% hObject    handle to pop_FD_fuel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit_FD_phi_Callback(hObject, eventdata, handles)
% hObject    handle to edit_FD_phi (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
datEdit = str2double(get(hObject, 'String'));
ValDefault = 1; 
if isnan(datEdit) || ~isreal(datEdit) ||datEdit < 0
    set(hObject, 'String', ValDefault);
    errordlg('Input must be a non-negative real number','Error');
    % when the input is not a number, it is set to the default value
end
GUI_INI_TP_disable_button(hObject)

% --- Executes during object creation, after setting all properties.
function edit_FD_phi_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_FD_phi (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit_FD_dilute_Callback(hObject, eventdata, handles)
% hObject    handle to edit_FD_dilute (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
datEdit = str2double(get(hObject, 'String'));
ValDefault = 0; 
if isnan(datEdit) || ~isreal(datEdit) ||datEdit < 0
    set(hObject, 'String', ValDefault);
    errordlg('Input must be a non-negative real number','Error');
    % when the input is not a number, it is set to the default value
end
GUI_INI_TP_disable_button(hObject)

% --- Executes during object creation, after setting all properties.
function edit_FD_dilute_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_FD_dilute (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit_TD_Tratio_Callback(hObject, eventdata, handles)
% hObject    handle to edit_TD_Tratio (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
datEdit = str2double(get(hObject, 'String'));
ValDefault = 1; 
if isnan(datEdit) || ~isreal(datEdit) ||datEdit < 0
    set(hObject, 'String', ValDefault);
    errordlg('Input must be a non-negative real number','Error');
    % when the input is not a number, it is set to the default value
end
GUI_INI_TP_disable_button(hObject)

% --- Executes during object creation, after setting all properties.
function edit_TD_Tratio_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_TD_Tratio (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit_HR_Callback(hObject, eventdata, handles)
% hObject    handle to edit_HR (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_HR as text
%        str2double(get(hObject,'String')) returns contents of edit_HR as a double


% --- Executes during object creation, after setting all properties.
function edit_HR_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_HR (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% ----------------Flame distribution pannel--------------------------------
%
% --- Executes on selection change in pop_FlameDistStyle.
function pop_FlameDistStyle_Callback(hObject, eventdata, handles)
% hObject    handle to pop_FlameDistStyle (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns pop_FlameDistStyle contents as cell array
%        contents{get(hObject,'Value')} returns selected item from pop_FlameDistStyle


% --- Executes during object creation, after setting all properties.
function pop_FlameDistStyle_CreateFcn(hObject, eventdata, handles)
% hObject    handle to pop_FlameDistStyle (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% ----------------Flame distribution pannel--------------------------------
%
function edit_DT_flameW_Callback(hObject, eventdata, handles)
% hObject    handle to edit_DT_flameW (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
datEdit = str2double(get(hObject, 'String'));
if isnan(datEdit)
    set(hObject, 'String', 0);
    errordlg('Input must be a number','Error');
end
GUI_INI_TP_disable_button(hObject)
%
% --- Executes during object creation, after setting all properties.
function edit_DT_flameW_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_DT_flameW (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
%
function edit_DT_SN_Callback(hObject, eventdata, handles)
% hObject    handle to edit_DT_SN (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_DT_SN as text
%        str2double(get(hObject,'String')) returns contents of edit_DT_SN
%        as a double
%
% --- Executes during object creation, after setting all properties.
function edit_DT_SN_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_DT_SN (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
%
% --- Executes on selection change in pop_DT_distS.
function pop_DT_distS_Callback(hObject, eventdata, handles)
% hObject    handle to pop_DT_distS (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns pop_DT_distS contents as cell array
%        contents{get(hObject,'Value')} returns selected item from
%        pop_DT_dist
%
% --- Executes during object creation, after setting all properties.
function pop_DT_distS_CreateFcn(hObject, eventdata, handles)
% hObject    handle to pop_DT_distS (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% ----------------Plot pannel----------------------------------------------
%
% --- Executes on selection change in pop_plot.
function pop_plot_Callback(hObject, eventdata, handles)
% hObject    handle to pop_plot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
Fcn_GUI_INI_TP_plot(handles.axes1,handles)
catch
end

% --- Executes during object creation, after setting all properties.
function pop_plot_CreateFcn(hObject, eventdata, handles)
% hObject    handle to pop_plot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pb_Plot.
function pb_Plot_Callback(hObject, eventdata, handles)
% hObject    handle to pb_Plot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Fcn_GUI_INI_TP_PLOT(hObject)
Fcn_GUI_INI_TP_plot(handles.axes1,handles)

% --- Executes on button press in pb_saveFig.
function pb_saveFig_Callback(hObject, eventdata, handles)
% hObject    handle to pb_saveFig (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles=guidata(hObject);
Fig = figure;
set(Fig,        'units','points')
posFig = get(handles.figure,'position');
copyobj(handles.axes1, Fig);
hAxes = get(Fig,'children');
set(hAxes,      'units','points',...
                'position',[60 60 200 200])
posAxesOuter = [0 0 300 300];
set(Fig,        'units','points',...
                'position', [posFig(1)+0.5*posFig(3)-0.5*posAxesOuter(3),...
                            posFig(2)+0.5*posFig(4)-0.5*posAxesOuter(4),...
                            posAxesOuter(3:4)])           


% --- Executes on button press in pb_Cal.
function pb_Cal_Callback(hObject, eventdata, handles)
% hObject    handle to pb_Cal (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
guidata(hObject, handles);
% --------------------Msg box ---------------------------------------------
%
hMsg = msgbox('The calculation may take several seconds, please wait!','Calculation...');

% B.B. 05/07/2019 START
%This ensures that the heat exchanger mean flow calculations are renewed
%if the mean flow properties are changed!
global CI
if (isfield(CI,'BC')) && (isfield(CI.BC,'hx')) && (isfield(CI.BC.hx,'isSetup')) && (CI.BC.hx.isSetup == true)
    CI.BC.hx.meanFlowCalc = false;
end
assignin('base','CI',CI)
% B.B. 05/07/2019 STOP

%
hChildren       = get(hMsg,'children');
% ok is changed to children(1) 
Vcur = version('-release')
if strcmp(Vcur,'2015a') == 1 || strcmp(Vcur,'2014b') == 1
    set(hChildren(1),       'units', 'points',...
                            'Fontunits','points',...
                            'fontsize',handles.FontSize(2),...
                            'string','OK',...
                            'backgroundcolor',handles.bgcolor{3},...
                            'visible','off',...
                            'enable','off')
elseif strcmp(version,'2014a') == 1 || strcmp(version,'2013b') == 1
    set(hChildren(2),       'units', 'points',...
                        'Fontunits','points',...
                        'fontsize',handles.FontSize(2),...
                        'string','OK',...
                        'backgroundcolor',handles.bgcolor{3},...
                        'visible','off',...
                        'enable','off')
end                   
%
pause(1)                % paus 1 second
delete(hMsg)
%
HA_num      = get(handles.pop_HA_num,'value');  % get the order of current HA 
Fcn_GUI_INI_TP_HA_UI2Para(hObject,HA_num)       % update HA parameters by the values from UI
%---------------------Main calculation ------------------------------------
Fcn_GUI_INI_TP_Main_calculation(hObject)
set(handles.pb_Cal,             'enable','on');
set(handles.pb_Plot,            'enable','on');
set(handles.pb_saveFig,         'enable','on');
set(handles.pb_OK,              'enable','on');
guidata(hObject, handles);
Fcn_GUI_INI_TP_plot(handles.axes1,handles);
handles = guidata(hObject);
guidata(hObject, handles);
% -------------------------------------------------------------------------



% --- Executes on button press in pb_OK.
function pb_OK_Callback(hObject, eventdata, handles)
% hObject    handle to pb_OK (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
guidata(hObject, handles);
%
Fcn_GUI_INI_TP_Update(hObject, eventdata, handles)
%
handles = guidata(hObject);
guidata(hObject, handles);
global CI
CI.IsRun.GUI_INI_TP = 1;
assignin('base','CI',CI); 
delete(handles.figure);

% --- Executes on button press in pb_Cancel.
function pb_Cancel_Callback(hObject, eventdata, handles)
% hObject    handle to pb_Cancel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
delete(handles.figure);

% --- Executes when user attempts to close figure.
function figure_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to figure (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: delete(hObject) closes the figure
delete(hObject);


% --------------------------------------------------------------------
function uipushtool1_ClickedCallback(hObject, eventdata, handles)
% hObject    handle to uipushtool1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles=guidata(hObject);
Fig = figure;
set(Fig,        'units','points')
posFig = get(handles.figure,'position');
copyobj(handles.axes1, Fig);
hAxes = get(Fig,'children');
set(hAxes,      'units','points',...
                'position',[60 60 200 200])
posAxesOuter = [0 0 300 300];
set(Fig,        'units','points',...
                'position', [posFig(1)+0.5*posFig(3)-0.5*posAxesOuter(3),...
                            posFig(2)+0.5*posFig(4)-0.5*posAxesOuter(4),...
                            posAxesOuter(3:4)])       


% --- Executes on selection change in pop_gamma.
function pop_gamma_Callback(hObject, eventdata, handles)
% hObject    handle to pop_gamma (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns pop_gamma contents as cell array
%        contents{get(hObject,'Value')} returns selected item from pop_gamma


% --- Executes during object creation, after setting all properties.
function pop_gamma_CreateFcn(hObject, eventdata, handles)
% hObject    handle to pop_gamma (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
